package com.acwing.partition19;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author `RKC`
 * @date 2022/1/24 17:45
 */
public class AC1875贝茜的报复 {

    private static Map<Integer, List<Integer>> map = new HashMap<>(7);

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(reader.readLine());
        while (n-- > 0) {
            String[] s = reader.readLine().split(" ");
            int key = s[0].charAt(0) - 'A';
            List<Integer> val = map.getOrDefault(key, new ArrayList<>());
            val.add(Integer.parseInt(s[1]));
            map.put(key, val);
        }
        int sum = 1;
        for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
            sum *= entry.getValue().size();
        }
        //(B+2*E+2*S+I)(G+O+E+S)(M+2*O)  => (B+I是奇数)(G+O+E+S是奇数)(M是奇数)
        //只有三个括号内的值都为奇数，才会是奇数；用总数减去奇数的情况
        int c1 = 0, c2 = 0, c3 = 0;
        for (int v1 : map.get('B' - 'A')) {
            for (int v2 : map.get('I' - 'A')) {
                if ((v1 + v2 & 1) == 1) c1++;
            }
        }
        for (int v1 : map.get('G' - 'A')) {
            for (int v2 : map.get('O' - 'A')) {
                for (int v3 : map.get('E' - 'A')) {
                    for (int v4 : map.get('S' - 'A')) {
                        if (((v1 + v2 + v3 + v4) & 1) == 1) c2++;
                    }
                }
            }
        }
        for (int v1 : map.get('M' - 'A')) {
            if ((v1 & 1) == 1) c3++;
        }
        writer.write((sum - c1 * c2 * c3) + "\n");
        writer.flush();
    }
}
